/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package accountmanager.dao.impl;

import accountmanager.dao.ifc.ClienteDAO;
import accountmanager.dao.Cliente;
import java.util.ArrayList;

/**
 *
 * @author Afonso
 */
public class MemoryClienteDAO implements ClienteDAO {

    private MemoryClienteDAO memoryClienteDAO = null;

    private ArrayList<Cliente> clientes = new ArrayList<Cliente>();

    public Cliente buscaClienteCpf(long cpf) {
        Cliente cliente = null;
        for (Cliente c:clientes) {
            if (cpf == c.getCpf())
                cliente = c;
        }

        return cliente;
    }

    public ArrayList<Cliente> buscaTodosCliente() {
        return clientes;
    }

    public boolean cadastraCliente(long cpf, String nome) {
        if (buscaClienteCpf(cpf) == null)
            clientes.add(new Cliente(cpf, nome));
        else
            return false;

        return true;
    }

}
